<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>完美校园Scheme生成</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport"
          content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>

    <style>
        .divider {
            margin-top: 20px;
            margin-bottom: 20px;
        }
    </style>
</head>
<body style="padding-bottom: 50pt">

<div style="display: flex;flex-direction: row;align-items: center; ">
    <h3>完美校园Scheme生成</h3>
    <a style="margin-left: 20px" href="javascript:location.reload()"><h5>刷新</h5></a>
</div>

<script>
    const iosParam = "&iosLaunchType=iosLaunchType";

    function copyScheme(scheme) {
        navigator.clipboard.writeText(scheme).then(() => {
            alert("已复制到剪切板")
        })
    }

    function createATag(scheme) {
        const aTag = document.createElement("a");
        aTag.href = scheme;
        aTag.textContent = scheme;
        return aTag;
    }

    function createScheme(type, data) {
        let scheme = "wanxiao://17wanxiao.com?page=" + type + iosParam;
        if (data) {
            scheme += "&data=" + data
        }
        return scheme
    }

    function createSchemeEncode(type, data) {
        let scheme = "wanxiao://17wanxiao.com?page=" + type + iosParam;
        if (data) {
            scheme += "&data=" + encodeURIComponent(data)
        }
        return scheme
    }
</script>
<div>
    <h4>无参数scheme</h4>
    <select id="noParamSchemeType" onchange="genNoParamScheme()">
        <option value="" selected>请选择</option>
        <option value="chargeMoney">充值页面</option>
        <option value="bindEcard">绑卡</option>
        <option value="oneKeyRechargeSetting">一键充值设置(v5.8.18)</option>
        <option value="noticeCenter">通知</option>
        <option value="scanCheckUrl">扫一扫</option>
    </select>
    <div style="margin-top: 10px; word-break: break-all" id="noParamScheme">
    </div>
    <script>
        function genNoParamScheme() {
            let type = document.getElementById("noParamSchemeType").value;
            if (type) {
                let scheme = createSchemeEncode(type);
                document.getElementById("noParamScheme").innerText = "";
                document.getElementById("noParamScheme").appendChild(createATag(scheme));
                copyScheme(scheme)
            }
        }
    </script>

</div>
<hr class="divider">

<div>
    <h4>WebView</h4>
    <table style="margin-top: 10px;width: 100%;">
        <tr>
            <td style="width: 45pt; vertical-align: top">url:</td>
            <td><input style="width: 100%" id="web_view_url" type="text" value="https://"><br>
                <label style="color: red; font-size: 15px">*确保输入的url可以正常访问</label>
            </td>
        </tr>
    </table>
    <div style="margin-top: 10px; word-break: break-all" id="webViewScheme">
    </div>
    <input style="margin-top: 10px; width: 50pt;height: 20pt" type="button" value="生成" onclick="genWebViewScheme()">
    <script>
        function genWebViewScheme() {
            const type = "webBrowser";
            let url = document.getElementById("web_view_url").value;
            if (url) {
                let data = JSON.stringify({
                    url: url
                });
                let scheme1 = createScheme(type, data);
                let scheme2 = createSchemeEncode(type, data);
                document.getElementById("webViewScheme").innerText = scheme1 + "\n";
                document.getElementById("webViewScheme").appendChild(createATag(scheme2));
                copyScheme(scheme2)
            }
        }
    </script>
</div>

<hr class="divider">
<div>
    <h4>打开微信小程序</h4>
    <table style="margin-top: 10px;width: 100%;">
        <tr>
            <td style="width: 45pt">原始id:</td>
            <td><input style="width: 100%" id="wx_mini_id" type="text"></td>
        </tr>
        <tr>
            <td style="width: 45pt">Path:</td>
            <td><input style="width: 100%" id="wx_mini_path" type="text"></td>
        </tr>
        <tr>
            <td style="width: 45pt">type:</td>
            <td><select id="wx_mini_type">
                <option value="0" selected>正式版</option>
                <option value="1">开发版</option>
                <option value="2">体验版</option>
            </select></td>
        </tr>
    </table>
    <div style="margin-top: 10px; word-break: break-all" id="wx_mini_scheme_result"></div>
    <input style="margin-top: 10px; width: 50pt;height: 20pt" type="button" value="生成" onclick="genWxMinScheme()">
    <script>
        function genWxMinScheme() {
            const type = "wxMini";
            const id = document.getElementById("wx_mini_id").value;
            if (!id) {
                alert("请输入原始id");
                return
            }
            const path = document.getElementById("wx_mini_path").value;
            const vType = document.getElementById("wx_mini_type").value;
            const data = JSON.stringify({
                userName: id,
                path: path ? path : undefined,
                type: vType
            });
            const scheme1 = createScheme(type, data);
            const scheme2 = createSchemeEncode(type, data);
            document.getElementById("wx_mini_scheme_result").innerText = scheme1 + "\n";
            document.getElementById("wx_mini_scheme_result").appendChild(createATag(scheme2));
            copyScheme(scheme2)
        }
    </script>
</div>

<hr class="divider">
<div>
    <h4>虚拟卡</h4>
    <label for="vc_version">版本：</label><select id="vc_version" onchange="genVCScheme()">
    <option value="" selected>请选择</option>
    <option value="0">新版</option>
    <option value="1">老版</option>
</select>
    <div style="margin-top: 10px; word-break: break-all" id="vcScheme">
    </div>
    <script>
        function genVCScheme() {
            let scheme = "wanxiao://17wanxiao.com?page=virtualEcard" + iosParam;
            const version = document.getElementById("vc_version").value;
            if (version === "1") {
                let data = JSON.stringify({
                    version: "old"
                });
                let scheme1 = scheme + "&data=" + data;
                let scheme2 = scheme + "&data=" + encodeURIComponent(data);
                document.getElementById("vcScheme").innerText = scheme1 + "\n";
                document.getElementById("vcScheme").appendChild(createATag(scheme2));
                copyScheme(scheme2)
            } else {
                document.getElementById("vcScheme").innerText = "";
                document.getElementById("vcScheme").appendChild(createATag(scheme));
                copyScheme(scheme)
            }
        }
    </script>
</div>


</body>
</html>
